home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Invisible Universe
/
Invisible Universe (1995)(Voyager)[Mac-PC].iso
/
mac
/
UNIVERSE
/
SHARED.DIR
/
01020_Script_underline and bold handlers
< prev
next >
Wrap
Text File
|
1995-11-21
|
5KB
|
200 lines
on doTextClick cn
global gMouseDownTime, gPunctuation, gUnderlineCount
--put ">>>doTextClick on " & cn
if the ticks < (gMouseDownTime + 80) then exit
--beep
set mw = the mouseWord
set mc = the mouseChar
if voidP(cn) then
set cn = the mouseCast
end if
if voidP(gPunctuation) then
set gUnderlineCount = length(field "Underline List")
set gPunctuation = ":,.;)( " & quote & return
end if
if (the castType of cast cn) <> #text then exit
set ts = the textStyle of word mw of field cn
if ts = "plain" then exit
if ts = "bold" then
doBoldText mw, cn
else
doUnderlineText mc, cn
end if
end doTextClick
on doBoldText mw, cn
global gPunctuation
set thePhrase = word mw of field cn
set i = mw - 1
repeat while i > 0
if (the textStyle of word i of field cn) <> "bold" then exit repeat
set thePhrase = word i of field cn && thePhrase
set i = i - 1
end repeat
set i = mw + 1
set last = the number of words of field cn
repeat while i < last
if (the textStyle of word i of field cn) <> "bold" then exit repeat
set thePhrase = thePhrase && word i of field cn
set i = i + 1
end repeat
set l = the number of chars in thePhrase
repeat while gPunctuation contains (char l of thePhrase)
set l = l - 1
if l = 0 then
alert "Note that word " & mw && "of cast" && cn && "is only punctuation."
return
end if
end repeat
set thePhrase = char 1 to l of thePhrase
--put ">>>doTextClick: bold" && thePhrase
set off = offset(thePhrase, field "BOLD List")
if off <> 0 then
--- tbd dmd remove line ???
if char (off-1) of field "BOLD List" <> ">" then
alert ¼
"Minor error in doTextClick for bold field... missing " & quote ">" & quote
end if
set lineNum = integer(char (off-3) to (off-2) of field "BOLD List")
--put ">>>line = " & line lineNum of field "Bold List"
--
--
-- Note that item 4 contains a value if we need a unique match on
-- both the term and the cast member
--
if empty <> item 4 of line lineNum of field "BOLD List" then
repeat while 1
--
--
-- Check for a matching cast member
--
if cn = integer(item 2 of line lineNum of field "BOLD List") then exit repeat
--put ">>> going to next line"
--
--
-- Try the next item in the list
--
set lineNum = lineNum + 1
set newPhrase = item 1 of line lineNum of field "BOLD List"
set l = the number of chars in newPhrase
set newPhrase = char 5 to l of newPhrase
--
--
-- Check if the next term matches, if not, exit.
--
if newPhrase <> thePhrase then
set off = 0
exit repeat
end if
end repeat
end if
end if
--
--
-- Do the bold goto
--
--put ">>> BOLD click: " & thePhrase & " takes you to " & item 3 of line lineNum of field "BOLD List"
if off > 0 then
goGo(item 3 of line lineNum of field "BOLD List")
exit
else
alert "The BOLD term clicked was: " & quote & thePhrase & quote && "in cast " & cn ¼
& ", but it can not be found in the bold list."
exit
end if
end doBoldText
on doUnderlineText mc, cn
global gGlossPalette, gPunctuation
cursor 4
set thePhrase = char mc of field cn
set i = mc - 1
repeat while i > 0
if (the textStyle of char i of field cn) <> "underline" then exit repeat
set thePhrase = char i of field cn & thePhrase
set i = i - 1
end repeat
set i = mc + 1
set last = the number of chars of field cn
repeat while i <= last
if (the textStyle of char i of field cn) <> "underline" then exit repeat
set thePhrase = thePhrase & char i of field cn
set i = i + 1
end repeat
set l = the number of chars in thePhrase
repeat while gPunctuation contains (char l of thePhrase)
set l = l - 1
end repeat
set thePhrase = char 1 to l of thePhrase
--put ">>>doTextClick: underline" && thePhrase
set glossCN = underLineLookUp(thePhrase, cn)
if glossCN = 0 then
alert "Term not found in the glossary. Term clicked was: " ¼
& quote & thePhrase & quote && "in cast " & cn
else
if voidP(gGlossPalette) then
createGlossPalette
end if
tell gGlossPalette to showTermCast(glossCN)
tell gGlossPalette to lOpenGlossPalette
end if
cursor -1
end doUnderlineText